import request from '@/utils/requestA'
/**
 * 注册接口
 * @param {*} param0 { username: 用户名, password: 密码 }
 * @returns Promise对象
 */
// export const login = ({ username, password }) => {
//   return request({
//     url: '/login',
//     method: 'Get',
//     params: {
//       username,
//       password
//     }
//   })
// }
export const getuser = () => {
  return request({
    url: '/userInfo/getAllStuUsers',
    method: 'Get'
  })
}
export const getdept = () => {
  return request({
    url: '/sys/dept',
    method: 'Get'
  })
}
// pagenum: 当前页码数, pagesize: 当前页条数
// export const inituser = (pagenum, pagesize) => {
//   return request({
//     url: '/sys/inituserinfo',
//     method: 'Get',
//     params: {
//       pagenum,
//       pagesize

//     }
//   })
// }

export const registerAPI = (nickname, username, password) => {
  return request({
    url: '/register',
    method: 'post',
    data: {
      nickname,
      username,
      password
    }
  })
}
// page: 当前页码数, limit: 当前页条数
export const inituser = (page, limit) => {
  return request({
    url: '/userInfo/findUserByPageAndLimit',
    method: 'Get',
    params: {
      page,
      limit
    }
  })
}

// 编辑用户
export const edituser = (
  adminId,
  adminNum,
  stuId,
  stuNum,
  stuName,
  stuAge,
  stuSex,
  stuAddress,
  stuMajor,
  stuGrade,
  stuPhone,
  stuPassword,
  stuSelfcrisis,
  stuHead) => {
  return request({
    url: '/userInfo/updateStudentById',
    method: 'post',
    data: {
      adminId,
      adminNum,
      stuId,
      stuNum,
      stuName,
      stuAge,
      stuSex,
      stuAddress,
      stuMajor,
      stuGrade,
      stuPhone,
      stuPassword,
      stuSelfcrisis,
      stuHead
    }
  })
}
export const updateSysUserStatus = (id, status) => {
  return request({
    url: '/updateSysUserStatus',
    method: 'post',
    data: {
      id, status
    }
  })
}
export const addSysUserApI = (stuNum,
  stuName,
  stuAge,
  stuSex,
  stuAddress,
  stuMajor,
  stuGrade,
  stuPhone,
  stuPassword,
  stuSelfcrisis,
  adminId,
  adminNum) => {
  return request({
    url: '/userInfo/addUser',
    method: 'post',
    data: {
      stuNum,
      stuName,
      stuAge,
      stuSex,
      stuAddress,
      stuMajor,
      stuGrade,
      stuPhone,
      stuPassword,
      stuSelfcrisis,
      adminId,
      adminNum
    }
  })
}

export const delteStuById = (stu_id) => {
  return request({
    url: '/userInfo/delteStuById',
    method: 'post',
    data: {
      stu_id
    }
  })
}
export const deleteStudents = (ids) => {
  return request({
    url: '/userInfo/deleteStudents',
    method: 'post',
    data: {
      ids
    }
  })
}

export const findSysUserByNameApI = (admin_phone) => {
  return request({
    url: '/userInfo/findSysUserByName',
    method: 'get',
    params: {
      admin_phone
    }

  })
}

export const findStudentBy = (select) => {
  return request({
    url: '/userInfo/findStudentBy',
    method: 'get',
    params: {
      select
    }

  })
}

export const fileUpload = (file, stuId) => {
  return request({
    url: '/userInfo/upload',
    method: 'post',
    data: {
      file,
      stuId
    }
  })
}


export const updatePwdAPI = (id, password) => {
  return request({
    url: '/updateSysUserPasswordById',
    method: 'post',
    data: {
      id, password
    }
  })
}
export const findUserInfoById = id => {
  return request({
    url: '/userInfo/findStudentById',
    method: 'get',
    params: {
      id
    }
  })
}

/*export const fileUpload = (file, stuId) => {
  return request({
    url: '/userInfo/upload',
    method: 'post',
    data: {
      file,
      stuId
    }
  })
}*/

//根据id查初访
export const reqGetConsultInfo = (id) => {
  return request({
    url: '/userInfo/GetConsultInfo',
    method: 'get',
    params: {
      id
    }
  })
}
export const reqGetConsultByVisit = (id) => {
  return request({
    url: '/consultInfo/GetConsultByVisits',
    method: 'post',
    data: {
      id
    }
  })
}

export const findUserInfoById = id => {
  return request({
    url: '/userInfo/findStudentById',
    method: 'get',
    params: {
      id
    }
  })
}
export const fileUpload = (file, stuId) => {
  return request({
    url: '/userInfo/upload',
    method: 'post',
    data: {
      file,
      stuId
    }
  })
}



// 编辑用户
export const UpdateHead = (
  adminId,
  adminNum,
  stuId,
  stuNum,
  stuName,
  stuAge,
  stuSex,
  stuAddress,
  stuMajor,
  stuGrade,
  stuPhone,
  stuPassword,
  stuSelfcrisis,
  stuHead) => {
  return request({
    url: '/userInfo/UpdateHead',
    method: 'post',
    data: {
      adminId,
      adminNum,
      stuId,
      stuNum,
      stuName,
      stuAge,
      stuSex,
      stuAddress,
      stuMajor,
      stuGrade,
      stuPhone,
      stuPassword,
      stuSelfcrisis,
      stuHead
    }
  })
}